<template>
  <section>
    <div class="model retrieval">
      <img :src="IMGBASE64.JIANSUOGUANLI2X" class="orange">
      <span class="title">检索管理</span>
      <div class="body">
        <span>年级:</span>
        <select class="select" v-model="gradeSelect" :style="{background: `url(${IMGBASE64.SELECT}) no-repeat scroll right center`}">
          <option v-for="(item, key) in gradeOption" :label="item" :value="key"></option>
        </select>
        <el-button type="primary" size="small" @click="searchData">搜索</el-button>
        <el-button type="primary" size="small" @click="clearData">重置</el-button>
        <!-- <div class="right">
          <el-select v-model="selectValue" filterable clearable placeholder="请输入教师姓名" size="small">
            <el-option
              v-for="item in teacherList"
              :label="item.name"
              :value="item.id">
            </el-option>
          </el-select>
          <el-button type="primary" size="small" @click="searchData">搜索</el-button>
        </div> -->
      	<div class="newadd"><el-button type="success" @click="upshow()" size="small">新建</el-button></div>
      </div>
    </div>
    <div class="model management">
      <img :src="IMGBASE64.JIAOSHXINXIIGUANLI2X" class="pink">
    	<span class="title">教师管理</span>
    	<div class="kong"></div>
    	<template>
    		<el-table :data="teacherData" style="width: 100%">
    			<el-table-column prop="gradeText" label="年级" min-width="100" align="center"></el-table-column>
    			<el-table-column prop="clazz" label="班级" min-width="80" align="center" :show-overflow-tooltip='true'></el-table-column>
    			<el-table-column prop="classTeacher" label="班主任" min-width="140" align="center" :show-overflow-tooltip='true'></el-table-column>
    			<el-table-column prop="deputyClassTeacher" label="副班主任" min-width="100" align="center"></el-table-column>
    			<el-table-column prop="chineseTeacher" label="语文老师" min-width="100" align="center"></el-table-column>
    			<el-table-column prop="mathTeacher" label="数学老师" width="180" align="center" :show-overflow-tooltip='true'></el-table-column>
    			<el-table-column prop="englishTeacher" label="英语老师" min-width="100" align="center" :show-overflow-tooltip='true'></el-table-column>
          <el-table-column prop="lifeTeacher" label="生活老师" min-width="100" align="center"></el-table-column>
    			<el-table-column label="操作" align="center" min-width="150">
    				<template scope="scope">
    					<el-button size="small" @click="showDetails(scope)">修改</el-button>
              <el-button size="small" @click="deleteData(scope)">删除</el-button>
    				</template>
    			</el-table-column>
    		</el-table>
        <el-pagination
          v-show="paging"
          @current-change="handleCurrentChange"
          :page-size="20"
          layout="prev, pager, next, jumper"
          :total="total"
          class="pull-right">
        </el-pagination>
    	</template>
    </div>

    <div class="bigUp" v-show="upShow">
      <img :src="IMGBASE64.GREENXINZENG2X" class="img">
      <span class="title">新增班级</span>
      <el-button icon="el-icon-close" class="close" @click="upshow()"></el-button>
      <div class="header">
        <span class="header-title">基本信息</span>
      </div>
      <el-form ref="form" :model="form" label-width="110px">
        <el-col :span="24">
          <el-form-item label="年级">
            <el-select v-model="gradeSelectN" @change="getLastClass()" style='width: 30%;' size="small">
              <el-option v-for="(item, key) in gradeOption" :label="item" :value="key"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="班级">
            <el-select v-model="classSelectN" :disabled='true' style='width: 73%;' size="small">
              <el-option v-for="(item, key) in classOption" :label="item" :value="item"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11"><div class="kong1"></div></el-col>
        <el-col :span="11">
          <el-form-item label="班主任">
            <el-select v-model="form.headmaster" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;'>
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="副班主任">
            <el-select v-model="form.viceHeadmaster" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;' ref="tSe">
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="语文老师">
            <el-select v-model="form.chineseTeachet" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;' ref="tSe">
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="数学老师">
            <el-select v-model="form.mathTeachet" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;' ref="tSe">
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="英语老师">
            <el-select v-model="form.englishTeachet" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;' ref="tSe">
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="生活老师">
            <el-select v-model="form.lifeTeachet" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;' ref="tSe">
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-form>
      <el-col :span="24">
        <div class="bottom">
          <div class="left">
            <el-checkbox v-model="checked">继续新建</el-checkbox>
          </div>
          <div class="right">
            <el-button type="success" @click="sublist" size="small">确定</el-button>
            <el-button @click="upshow">取消</el-button>
          </div>
        </div>
      </el-col>
    </div>

    <div class="bigUp" v-show="xiugaiShow">
      <img :src="IMGBASE64.XIANGQING2X" class="img">
      <span class="title">修改</span>
      <el-button icon="el-icon-close" class="close" @click="closeXiugaishow()"></el-button>
      <div class="header">
        <span class="header-title">基本信息</span>
      </div>
      <el-form ref="form" :model="newform" label-width="110px">
        <el-col :span="24">
          <el-form-item label="年级">
            <el-select v-model="gradeSelectC" @change="getLastClass()" style='width: 30%;' size="small">
              <el-option v-for="(item, key) in gradeOption" :label="item" :value="key"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="班级">
            <el-select v-model="classSelectC" style='width: 73%;' size="small">
              <el-option v-for="(item, key) in classOption" :label="item" :value="item"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11"><div class="kong1"></div></el-col>
        <el-col :span="11">
          <el-form-item label="班主任">
            <el-select v-model="newform.headmaster" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;'>
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="副班主任">
            <el-select v-model="newform.viceHeadmaster" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;' ref="tSe">
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="语文老师">
            <el-select v-model="newform.chineseTeachet" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;' ref="tSe">
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="数学老师">
            <el-select v-model="newform.mathTeachet" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;' ref="tSe">
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="英语老师">
            <el-select v-model="newform.englishTeachet" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;' ref="tSe">
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="11">
          <el-form-item label="生活老师">
            <el-select v-model="newform.lifeTeachet" filterable clearable placeholder="请输入教师姓名" size="small" style='width: 90%;' ref="tSe">
              <el-option
                v-for="item in teacherNameData"
                :label="item.name"
                :value="item">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-form>
      <el-col :span="24">
        <div class="bottom">
          <div class="left">
            <el-checkbox v-model="checked">继续新建</el-checkbox>
          </div>
          <div class="right">
            <el-button type="success" @click="changeData" size="small">确定</el-button>
          </div>
        </div>
      </el-col>
    </div>

    <!-- <div class="details" v-show="isDetails">
      <img :src="IMGBASE64.XIANGQING2X" class="icon">
      <span class="title">详情</span>
      <el-button icon="close" class="close" @click="detailsShow()"></el-button>
      <div class="body">
        <el-form label-width="80px">
          <el-col :span="24">
            <el-form-item label="姓名">
              <span>{{detailsForm.name}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="联系方式">
              <span>{{detailsForm.mobile}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="身份证号">
              <span>{{detailsForm.idNo}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="年级">
              <span>{{detailsForm.grade}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="学科">
              <span>{{detailsForm.subject}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="身份">
              <span v-for="item in detailsForm.id">{{item}}</span>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="现住地址">
              <span>{{detailsForm.homeAddr}}</span>
            </el-form-item>
          </el-col>
        </el-form>
      </div>
    </div>

    <div class="upload" v-show="upload">
      <el-button icon="close" class="close" @click="uploadshow()"></el-button>
      <div class="uploadButton">
        <el-upload
          class="upload-demo"
          ref="upload"
          action="http://119.23.36.128:8020/yxt-web/schoolConf/teacher/manage/query/export"
          :on-preview="handlePreview"
          :on-remove="removeFile"
          :on-change="choseFile"
          :auto-upload="false">
          <el-button slot="trigger" type="primary" :disabled="selectFile" size="small">选取文件</el-button>
          <el-button style="margin-left: 10px;" type="success" @click="submitUpload" size="small">上传到服务器</el-button>
        </el-upload>
      </div>
    </div> -->

    <transition name="modal-shadow">
      <div class="modal-backdrop" v-show="isSuccess"></div>
    </transition>
  </section>
</template>

<script>
export default {
  data () {
    return {
      teacherNameData: [],
      file: [],
      upload: false,
      selectFile: false,
      exportUrl: null,
      checked: false,
      upShow: false,
      xiugaiShow: false,
      isSuccess: false,
      isDetails: false,
      ncmClear: null,
      teacher: null,
      selectValue: null,
      teacherData: [],
      teacherList: [],
      gradeSelect: null,
      gradeSelectN: null,
      gradeSelectC: null,
      gradeOption: [],
      classSelect: null,
      classSelectN: null,
      classSelectC: null,
      classOption: [],
      subjectSelect: null,
      subjectOption: [],
      total: 0,
      page: 1,
      paging: true,
      state2: null,
      id: 0,
      allNameData: [],
      form: {
        grade: null,
        class: null,
        headmaster: null,
        headmasterN: null,
        viceHeadmaster: null,
        viceHeadmasterN: null,
        chineseTeachet: null,
        chineseTeachetN: null,
        mathTeachet: null,
        mathTeachetN: null,
        englishTeachet: null,
        englishTeachetN: null,
        lifeTeachet: null,
        lifeTeachetN: null
      },
      // newform: {
      //   id: null,
      //   grade: null,
      //   class: null,
      //   headmaster: null,
      //   headmasterN: null,
      //   viceHeadmaster: null,
      //   viceHeadmasterN: null,
      //   chineseTeachet: null,
      //   chineseTeachetN: null,
      //   mathTeachet: null,
      //   mathTeachetN: null,
      //   englishTeachet: null,
      //   englishTeachetN: null,
      //   lifeTeachet: null,
      //   lifeTeachetN: null
      // }
      newform: {
        id: null,
        grade: null,
        class: null,
        headmaster: {name: null, value: null},
        viceHeadmaster: {name: null, value: null},
        chineseTeachet: {name: null, value: null},
        mathTeachet: {name: null, value: null},
        englishTeachet: {name: null, value: null},
        lifeTeachet: {name: null, value: null}
      }
    }
  },
  mounted () {
    this.getGradeData()
    this.getTeacherNameData()
    this.exportUrl = this._exportUrl()
    this.xtoken = {'yxt-xtoken': localStorage.xtoken}
    this.$http.post(this._httpUrl + 'schoolConf/class/manage/classList', {
      rows: 20,
      page: this.page
    }, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
      if (response.body.code === '000') {
        this.teacherData = response.data.data.results
      } else if (response.body.code === '887') {
        this.$router.push('/')
      } else if (response.body.code === '889') {
        this.$router.push('/')
      }
    })
  },
  methods: {
    sublist () {
      this.$http.post(this._httpUrl + 'schoolConf/class/manage/addClass', {
        grade: this.gradeSelectN,
        clazz: this.classSelectN,
        classTeacher: this.form.headmaster.name,
        classTeacherId: this.form.headmaster.value,
        chineseTeacher: this.form.chineseTeachet.name,
        chineseTeacherId: this.form.chineseTeachet.value,
        mathTeacher: this.form.mathTeachet.name,
        mathTeacherId: this.form.mathTeachet.value,
        englishTeacher: this.form.englishTeachet.name,
        englishTeacherId: this.form.englishTeachet.value,
        deputyClassTeacher: this.form.viceHeadmaster.name,
        deputyClassTeacherId: this.form.viceHeadmaster.value,
        lifeTeacher: this.form.lifeTeachet.name,
        lifeTeacherId: this.form.lifeTeachet.value
      }, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
        if (response.body.code === '000') {
          this.gradeSelect = null
          this.classSelect = null
          this.form.headmasterN = null
          this.form.headmaster = null
          this.form.chineseTeachetN = null
          this.form.chineseTeachet = null
          this.form.mathTeachetN = null
          this.form.mathTeachet = null
          this.form.englishTeachetN = null
          this.form.englishTeachet = null
          this.form.viceHeadmasterN = null
          this.form.viceHeadmaster = null
          this.form.lifeTeachetN = null
          this.form.lifeTeachet = null
          this.upShow = !this.upShow
          this.isSuccess = !this.isSuccess
          this.$http.post(this._httpUrl + 'schoolConf/class/manage/classList', {
            rows: 20,
            page: this.page
          }, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
            if (response.body.code === '000') {
              this.teacherData = response.data.data.results
            } else if (response.body.code === '887') {
              this.$router.push('/')
            } else if (response.body.code === '889') {
              this.$router.push('/')
            }
          })
        }
      })
    },
    teacherSech (value) {
      // let obj = {}
      // obj = this.teacherNameData.find((item) => {
      //   return item.value === value
      // })
      // this.form.headmasterN = obj.name
      // this.form.chineseTeachetN = obj.name
      // this.form.mathTeachetN = obj.name
      // this.form.englishTeachetN = obj.name
      // this.form.viceHeadmasterN = obj.name
      // this.form.lifeTeachetN = obj.name
    },
    teacherSech1 (value) {
      // let obj = {}
      // obj = this.teacherNameData.find((item) => {
      //   return item.value === value
      // })
      // this.form.chineseTeachetN = obj.name
    },
    teacherSech2 (value) {
      // let obj = {}
      // obj = this.teacherNameData.find((item) => {
      //   return item.value === value
      // })
      // this.form.mathTeachetN = obj.name
    },
    teacherSech3 (value) {
      // let obj = {}
      // obj = this.teacherNameData.find((item) => {
      //   return item.value === value
      // })
      // this.form.englishTeachetN = obj.name
    },
    teacherSech4 (value) {
      // let obj = {}
      // obj = this.teacherNameData.find((item) => {
      //   return item.value === value
      // })
      // this.form.viceHeadmasterN = obj.name
    },
    teacherSech5 (value) {
      // let obj = {}
      // obj = this.teacherNameData.find((item) => {
      //   return item.value === value
      // })
      // this.form.lifeTeachetN = obj.name
    },
    _exportUrl () {
      let _cookie = document.cookie.split(';')
      let _cookieArray = []
      _cookie.forEach(v => {
        let _d = v.split('=')
        _cookieArray.push({
          key: _d[0],
          value: _d[1]
        })
      })
      return _cookieArray[0].value
    },
    upshow () {
      this.upShow = !this.upShow
      this.isSuccess = !this.isSuccess
      this.gradeSelect = null
      this.classSelect = null
      this.getAllData()
      // let _cookie = document.cookie.split(';')
      // let _cookieArray = []
      // _cookie.forEach(v => {
      //   let _d = v.split('=')
      //   _cookieArray.push({
      //     key: _d[0],
      //     value: _d[1]
      //   })
      // })
      // this.xtoken = {'yxt-xtoken': _cookieArray[0].value}
      // this.$http.post(this._httpUrl + 'schoolConf/teacher/manage/query', {}, {'headers': {'yxt-xtoken': _cookieArray[0].value}}).then(function (response) {
      //   if (response.body.code === '000') {
      //     let teacherList = []
      //     for (var i = 0; i < response.data.data.rows.length; i++) {
      //       teacherList.push({name: null, value: null})
      //       teacherList[i].name = response.data.data.rows[i].name
      //       teacherList[i].value = response.data.data.rows[i].id
      //     }
      //     this.teacherNameData = teacherList
      //     // console.log(teacherList)
      //   }
      // })
    },
    handleCurrentChange (val) {
      this.page = val
      this.xtoken = {'yxt-xtoken': localStorage.xtoken}
      this.$http.post(this._httpUrl + 'schoolConf/class/manage/classList', {
        rows: 20,
        page: this.page
      }, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
        if (response.body.code === '000') {
          this.teacherData = response.data.data.results
        } else if (response.body.code === '887') {
          this.$router.push('/')
        } else if (response.body.code === '889') {
          this.$router.push('/')
        }
      })
    },
    getTeacherNameData () {
      this.$http.post(this._httpUrl + 'schoolConf/class/manage/classList', {page: (this.page), rows: 20, grade: this.gradeSelect}, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
        if (response.body.code === '000') {
          this.total = response.data.data.totalPage * 20
        } else if (response.body.code === '887') {
          this.$router.push('/')
        } else if (response.body.code === '889') {
          this.$router.push('/')
        }
      })
    },
    getAllData () {
      this.$http.post(this._httpUrl + 'schoolConf/teacher/manage/query', {rows: this.total}, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
        if (response.body.code === '000') {
          let teacherList = []
          for (var i = 0; i < response.data.data.rows.length; i++) {
            teacherList.push({name: null, value: null})
            teacherList[i].name = response.data.data.rows[i].name
            teacherList[i].value = response.data.data.rows[i].id
          }
          this.teacherNameData = teacherList
        } else if (response.body.code === '887') {
          this.$router.push('/')
        } else if (response.body.code === '889') {
          this.$router.push('/')
        }
      })
    },
    getGradeData () {
      this.$http.post(this._httpUrl + 'public/grade/query ', {}, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
        if (response.body.code === '000') {
          this.gradeOption = response.data.data.gradeMap
        } else if (response.body.code === '887') {
          this.$router.push('/')
        } else if (response.body.code === '889') {
          this.$router.push('/')
        }
      })
    },
    getLastClass () {
      console.log(this.gradeSelectN)
      if (this.gradeSelectN !== null) {
        this.$http.post(this._httpUrl + 'public/class/query?grade=' + this.gradeSelectN, {}, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
          if (response.body.code === '000') {
            this.classOption = response.data.data
            console.log(this.classOption)
            this.classSelectN = this.classOption.length + 1
          } else if (response.body.code === '887') {
            this.$router.push('/')
          } else if (response.body.code === '889') {
            this.$router.push('/')
          }
        })
      }
    },
    searchData () {
      this.$http.post(this._httpUrl + 'schoolConf/class/manage/classList', {grade: this.gradeSelect, page: (this.page), rows: 20}, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
        if (response.body.code === '000') {
          this.teacherData = response.data.data.results
          // this.paging = false
        } else if (response.body.code === '887') {
          this.$router.push('/')
        } else if (response.body.code === '889') {
          this.$router.push('/')
        }
      })
    },
    changeData () {
      this.xtoken = {'yxt-xtoken': localStorage.xtoken}
      this.$http.post(this._httpUrl + 'schoolConf/class/manage/updateById', {
        id: this.newform.id,
        grade: this.gradeSelectC,
        clazz: this.classSelectC,
        classTeacher: this.newform.headmaster.name,
        classTeacherId: this.newform.headmaster.value,
        chineseTeacher: this.newform.chineseTeachet.name,
        chineseTeacherId: this.newform.chineseTeachet.value,
        mathTeacher: this.newform.mathTeachet.name,
        mathTeacherId: this.newform.mathTeachet.value,
        englishTeacher: this.newform.englishTeachet.name,
        englishTeacherId: this.newform.englishTeachet.value,
        deputyClassTeacher: this.newform.viceHeadmaster.name,
        deputyClassTeacherId: this.newform.viceHeadmaster.value,
        lifeTeacher: this.newform.lifeTeachet.name,
        lifeTeacherId: this.newform.lifeTeachet.value
      }, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
        if (response.body.code === '000') {
          this.xtoken = {'yxt-xtoken': localStorage.xtoken}
          this.$http.post(this._httpUrl + 'schoolConf/class/manage/classList', {
            rows: 20,
            page: this.page
          }, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
            if (response.body.code === '000') {
              this.teacherData = response.data.data.results
            } else if (response.body.code === '887') {
              this.$router.push('/')
            } else if (response.body.code === '889') {
              this.$router.push('/')
            }
          })
          this.xiugaiShow = !this.xiugaiShow
          this.isSuccess = !this.isSuccess
        } else if (response.body.code === '887') {
          this.$router.push('/')
        } else if (response.body.code === '889') {
          this.$router.push('/')
        }
      })
    },
    closeXiugaishow () {
      this.xiugaiShow = !this.xiugaiShow
      this.isSuccess = !this.isSuccess
    },
    detailsShow () {
      this.isDetails = !this.isDetails
      this.isSuccess = !this.isSuccess
    },
    clearData () {
      this.gradeSelect = null
    },
    deleteData (scope) {
      this.$http.post(this._httpUrl + 'schoolConf/class/manage/delById', {id: scope.row.id}, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
        if (response.body.code === '000') {
          this.$http.post(this._httpUrl + 'schoolConf/class/manage/classList', {
            rows: 20,
            page: this.page
          }, {'headers': {'yxt-xtoken': localStorage.xtoken}}).then(function (response) {
            if (response.body.code === '000') {
              this.teacherData = response.data.data.results
            } else if (response.body.code === '887') {
              this.$router.push('/')
            } else if (response.body.code === '889') {
              this.$router.push('/')
            }
          })
        } else if (response.body.code === '887') {
          this.$router.push('/')
        } else if (response.body.code === '889') {
          this.$router.push('/')
        }
      })
    },
    showDetails (scope) {
      this.gradeSelectC = scope.row.grade
      this.classSelectC = scope.row.clazz
      this.newform.id = scope.row.id
      this.newform.headmaster.name = scope.row.classTeacher
      this.newform.headmaster.value = scope.row.classTeacherId
      this.newform.chineseTeachet.name = scope.row.chineseTeacher
      this.newform.chineseTeachet.value = scope.row.chineseTeacherId
      this.newform.mathTeachet.name = scope.row.mathTeacher
      this.newform.mathTeachet.value = scope.row.mathTeacherId
      this.newform.englishTeachet.name = scope.row.englishTeacher
      this.newform.englishTeachet.value = scope.row.englishTeacherId
      this.newform.viceHeadmaster.name = scope.row.deputyClassTeacher
      this.newform.viceHeadmaster.value = scope.row.deputyClassTeacherId
      this.newform.lifeTeachet.name = scope.row.lifeTeacher
      this.newform.lifeTeachet.value = scope.row.lifeTeacherId
      this.xiugaiShow = !this.xiugaiShow
      this.isSuccess = !this.isSuccess
      console.log(scope.row)
      this.getAllData()
    }
  }
}
</script>

<style lang="less" scoped>
@import '/static/css/all-use.css';
  .kong1{
    padding: 31.5px;
  }
  .retrieval{
    .body{
      span{
      	margin-left: 5%;
      }
      span:first-child{
      	margin-left: 0;
      }
      .longSelect{
        width: 13%;
        border: 0;
        border-bottom: 1px solid #D7D7D7;
        appearance:none;
        -moz-appearance:none;
        -webkit-appearance:none;
        padding-left: 5px;
        padding-right: 18px;
      }
      .select{
        width: 13%;
        border: 0;
        border-bottom: 1px solid #D7D7D7;
        appearance:none;
        -moz-appearance:none;
        -webkit-appearance:none;
        padding-left: 5px;
        padding-right: 18px;
      }
      .right{
        width: 30%;
        display: inline-block;
        margin-left: 4%;
				&-text{
					width: 58%;
					border: 0;
					border-bottom: 1px solid #D7D7D7;
				}
				.search{
					background: #00A0E8;
					border: 0;
					border-radius: 2px;
					color: #fff;
					padding: 5px 15px;
				}
      }
      .newadd{
        float: right;
        margin-right: 10px;
      }
    }
  }
  
  .upload-demo{
    display: inline-block;
  }
  .close{
    position: absolute;
    right: 2%;
  }
  .bigUp{
    width: 54%;
    position: fixed;
    top: 30px;
    left: 50%;
    margin-left: -27%;
    background: #fff;
    border-radius: 5px;
    padding: 20px 20px 0 20px;
    z-index: 99999;
    .img{
      position: absolute;
      top: -24px;
      left: 25px;
    }
    .green{
      width: 64px;
      height: 64px;
      position: absolute;
      left: 3%;
      top: -20px;
      background: #0DBF9B;
      border-radius: 4px;
      text-align: center;
      line-height: 80px;
    }
    .title{
      margin-left: 96px;
    }
    .header{
      height: 24px;
      border-bottom: 2px solid #D7D7D7;
      padding: 30px 0 10px 0;
      margin-left: 3%;
      margin-bottom: 10px;
      &-title{
        height: 24px;
        display: inline-block;
        color: #FB7862;
        border-bottom: 2px solid #FB7862;
        padding: 0 0 10px 0;
        margin-left: 0;
      }
    }
    .select{
      border: 0;
      border-bottom: 1px solid #D7D7D7;
      appearance:none;
      -moz-appearance:none;
      -webkit-appearance:none;
      padding-left: 5px;
      padding-right: 18px;
    }
    .bottom{
      border-top: 1px solid #D7D7D7;
      margin-top: 20px;
      background: #F8F8F8;
      padding: 8px 0;
      margin-left: -20px;
      margin-right: -20px;
      border-radius: 0 0 5px 5px;
      .left{
        width: 50%;
        display: inline-block;
        margin-left: 2%;
      }
      .right{
        width: 43%;
        display: inline-block;
        text-align: right;
      }
    }
  }
  .error{
    color: #FF4949;
  }

  .upload{
    width: 20%;
    position: fixed;
    left: 50%;
    top: 200px;
    margin-left: -10%;
    background: #FFF;
    border-radius: 5px;
    z-index: 99999;
    padding: 10px 10px 10px 10px;
    text-align: center;
    .uploadButton{
      margin-top: 40px;
    }
  }

  .details{
  width: 55%;
  position: fixed;
  left: 25%;
  top: 60px;
  background: #FFF;
  border-radius: 5px;
  z-index: 99999;
  padding: 20px 10px 10px 10px;
  }
</style>
